import React from 'react';
import { Modal, DatePicker  } from 'antd';
import Grid from '../../components/table/grid';
import moment from 'moment';
import { injectIntl } from 'react-intl';
const { MonthPicker } = DatePicker;

class logQueryModal extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            refresh:0,
            curMonth:moment().format(`YYYYMM`)
        };
        const common = this.props.intl.messages.common;
        this.columns = [
            {
                title: common.repTime,
                dataIndex: 'time',
                key: 'time',
            },
            {
                title: common.statInfo,
                dataIndex: 'statusName',
                key: 'statusName',
            },

        ];
    }

    onChange=(date, dateString)=>{
        this.setState({
            curMonth:date?date.format(`YYYYMM`):''
        })
    }

    render() {
        const { visible, onCancel, selectedInfo } = this.props;
        const common = this.props.intl.messages.common;
        const monthFormat = 'YYYY/MM';
        return (
            <Modal
                wrapClassName="sass-tableWrapper"
                visible={visible}
                title={common.statLogger}
                onCancel={onCancel}
                footer={[<div key={1} style={{height:22}}></div>]}
            >
                <MonthPicker onChange={this.onChange} defaultValue={moment(this.state.curMonth, monthFormat)} format={monthFormat} style={{marginBottom:10}} allowClear={false}/>
                <Grid refresh={Symbol('fresh')} params={{stubId:selectedInfo.id||selectedInfo.stubId,month:this.state.curMonth}} columns={this.columns} url="api/stub/status/qry"/>
            </Modal>
        );
    }
}

export default injectIntl(logQueryModal)